import request from '@/utils/request'
const UpmsSystemService = {
  state: {},

  mutations: {},

  actions: {
    /**
     * 根据指定字段校验数据是否存在
     */
    systemValidateExistByField({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('system/validateExistByField', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 系统分页
     */
    pageSystem({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('system/page', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 系统保存
     */
    saveSystem({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('system/save', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 系统更新
     */
    updateSystem({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post(`system/update/${params.id}`, params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 系统删除
    */
    removeSystem({ commit }, ids) {
      return new Promise((resolve, reject) => {
        request.post('system/remove', ids).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 加载系统列表
    loadSystem({ commit }) {
      return new Promise((resolve, reject) => {
        request.get('system/loadSystem').then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 根据系统编号加载系统
    getSystemByCode({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('system/getByCode', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default UpmsSystemService
